﻿<UserControl x:Class="PrestoDashboard.Tabs.ResolveVariableView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="700">

    <UserControl.DataContext>
        <Binding Source="{StaticResource ResolveVariableViewModel}"/>
    </UserControl.DataContext>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="120"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Label Grid.Row="0" Grid.Column="0" Style="{StaticResource StandardLabel}" Content="Application:"/>

        <StackPanel Orientation="Horizontal" Height="25" Grid.Row="0" Grid.Column="1">
            <TextBox Text="{Binding ApplicationWithGroup.Application.Name}" Width="180" IsEnabled="False"/>
            <Button Content="..." Height="25" Width="25" Command="{Binding SelectApplicationCommand}" />
        </StackPanel>

        <Label Grid.Row="1" Grid.Column="0" Style="{StaticResource StandardLabel}" Content="Override Group:"/>

        <StackPanel Orientation="Horizontal" Height="25" Grid.Row="1" Grid.Column="1">
            <TextBox Text="{Binding ApplicationWithGroup.CustomVariableGroup.Name}" Width="180" IsEnabled="False"/>
            <Button Content="..." Height="25" Width="25" Command="{Binding SelectGroupCommand}"/>
            <Button Content="X" Width="25" Height="25" Command="{Binding RemoveGroupCommand}"/>
        </StackPanel>

        <Label Grid.Row="2" Grid.Column="0" Style="{StaticResource StandardLabel}" Content="Server:"/>

        <StackPanel Orientation="Horizontal" Height="25" Grid.Row="2" Grid.Column="1">
            <TextBox Text="{Binding ApplicationServer.Name}" Width="180" IsEnabled="False"/>
            <Button Content="..." Height="25" Width="25" Command="{Binding SelectServerCommand}" />
        </StackPanel>
        
        <DataGrid Grid.Row="3" Grid.ColumnSpan="2" AutoGenerateColumns="False" IsReadOnly="True" HeadersVisibility="Column"
                      ItemsSource="{Binding ResolvedCustomVariables}" CanUserSortColumns="True">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=Key}" Header="Variable" Width="220" SortMemberPath="Key"/>
                <DataGridTextColumn Binding="{Binding Path=Value}" Header="Value" Width="*"/>
            </DataGrid.Columns>
        </DataGrid>

        <Button Grid.Row="4" Grid.ColumnSpan="2" Style="{StaticResource StandardButton}" Content="Resolve" Command="{Binding ResolveCommand}"/>
        
    </Grid>
    
</UserControl>
